Transferred from: http://blog.csdn.net/anye3000/article/details/6593551Programmers with a history of C writing tend to like the printf function in particular. Even though simpler commands (such as puts) can be used, printf appears in the "hello of
Printf and sprintf are common and vsprintf is not.
1. Declaration of the three functions:
int printf (const char * szFormat, ...);int sprintf (char * szBuffer, const char * szFormat, ...);int vsprintf(char *string, char *format, va_list param);
2.
Instance
Write the formatted string to the variable:
Definition and usage
The vsprintf () function writes a formatted string to a variable.
Unlike sprintf (), the parameters in vsprintf () are in the array. The array elements are inserted into the
vsprintf
/* Function Name: vsprintf function: Send formatted output to string return value: Normally returns the length of the generated string (minus/0), and error conditions return negative usage: int vsprintf (char *string, Char *format,
The sprintf () format string is written to a variable.vsprintf () format the string in some of the write variables. Output: 123.000000456.000000 Grammar
sprintf(format,arg1,arg2,arg+ +)
Parameters
I. vfprintf
Function Name: vfprintf
Function: formatted data is output to the specified data stream.
Usage: int vfprintf (File * stream, char * format, va_list PARAM );
Function Description: vfprintf () will convert and format the data according to
Va_start,Function name, the process of reading a variable parameter is actually in the stack, using pointers, traversing the parameter list in the stack segment, from the low address to the high address one by one to read out the contents of the
Before this time, I always believe building the program with Unicode or non Unicode flag only effect the programatic side, and won't effect the system behavior. the problem arose with mixing usage of Multi-byte and Unicode Character Set
Vprintf, vfprintf, and vsprintf
Syntax:
# Include # include int vprintf (char * format, va_list arg_ptr); int vfprintf (File * stream, const char * format, va_list arg_ptr); int vsprintf (char * buffer, char * format, va_list
Study the implementation of printf. First, let's look at the function body of the printf function.Int printf (const char * fmt ,...){Int I;Char buf [256];Va_list arg = (va_list) (char *) (& fmt) + 4 );I = vsprintf (buf, fmt, arg );Write (buf, I
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.